<template>
  <div class="project-detail" v-if="project">
    <div class="project-header">
      <h1 v-text="project.title"></h1>
      <p class="project-category" v-text="project.category"></p>
    </div>
    
    <div class="project-image">
      <img :src="project.image" :alt="project.title">
    </div>
    
    <div class="project-content">
      <div class="project-description">
        <h2>项目描述</h2>
        <p v-text="project.description"></p>
      </div>
      
      <div class="project-details">
        <h2>项目详情</h2>
        <ul>
          <li><strong>创作时间:</strong> <span v-text="project.date"></span></li>
          <li><strong>创作工具:</strong> <span v-text="project.tools"></span></li>
          <li><strong>项目类型:</strong> <span v-text="project.type"></span></li>
        </ul>
      </div>
    </div>
  </div>
  
  <div class="project-not-found" v-else>
    <h1>项目未找到</h1>
    <p>抱歉，您访问的项目不存在。</p>
    <router-link to="/gallery" class="btn">返回作品画廊</router-link>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useRoute } from 'vue-router'

const route = useRoute()
const project = ref(null)

// 模拟项目数据
const projectData = [
  {
    id: 1,
    title: '城市夜景',
    category: '摄影',
    image: 'https://picsum.photos/seed/pd1/1200/800',
    description: '这组城市夜景作品拍摄于2023年夏季，捕捉了都市夜晚的繁华与宁静。通过长时间曝光技术，车流的轨迹形成了美丽的光带，展现了城市的活力。',
    date: '2023年7月',
    tools: '佳能 EOS R5, 24-70mm f/2.8镜头',
    type: '商业摄影'
  },
  {
    id: 2,
    title: '自然风光',
    category: '摄影',
    image: 'https://picsum.photos/seed/pd2/1200/800',
    description: '这组自然风光作品拍摄于山区，展现了大自然的壮丽与和谐。清晨的薄雾为山峦增添了神秘感，金色的阳光洒在湖面上，营造出宁静祥和氛围。',
    date: '2023年5月',
    tools: '尼康 D850, 14-24mm f/2.8镜头',
    type: '风景摄影'
  },
  {
    id: 3,
    title: '人物肖像',
    category: '摄影',
    image: 'https://picsum.photos/seed/pd3/1200/800',
    description: '这组人物肖像作品通过镜头捕捉了不同人物的内心世界。每张照片都展现了被摄者的独特个性和情感，通过光影的运用增强了画面的表现力。',
    date: '2023年3月',
    tools: '富士 X-T4, 56mm f/1.2镜头',
    type: '人像摄影'
  }
]

onMounted(() => {
  const projectId = parseInt(route.params.id)
  project.value = projectData.find(p => p.id === projectId) || null
})
</script>

<style scoped>
.project-detail {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.project-header {
  text-align: center;
  margin-bottom: 40px;
  padding: 30px 0;
  border-bottom: 1px solid #eee;
}

.project-header h1 {
  font-size: 2.8rem;
  margin-bottom: 15px;
  color: #333;
}

.project-category {
  color: #42b983;
  font-size: 1.3rem;
  font-weight: 500;
  display: inline-block;
  padding: 5px 15px;
  background-color: rgba(66, 185, 131, 0.1);
  border-radius: 20px;
}

.project-image img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  transition: transform 0.3s ease;
}

.project-image img:hover {
  transform: scale(1.02);
}

.project-content {
  margin-top: 40px;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 40px;
}

@media (max-width: 768px) {
  .project-content {
    grid-template-columns: 1fr;
  }
}

.project-description,
.project-details {
  margin-bottom: 30px;
}

.project-description h2,
.project-details h2 {
  font-size: 1.8rem;
  margin-bottom: 20px;
  color: #333;
  padding-bottom: 10px;
  border-bottom: 2px solid #42b983;
}

.project-description p {
  font-size: 1.1rem;
  line-height: 1.8;
  color: #555;
}

.project-details ul {
  list-style: none;
  padding: 0;
}

.project-details li {
  margin-bottom: 15px;
  padding: 15px;
  background-color: #f8f9fa;
  border-radius: 8px;
  font-size: 1.1rem;
  transition: transform 0.2s ease;
}

.project-details li:hover {
  transform: translateX(5px);
}

.project-details strong {
  color: #333;
  display: inline-block;
  width: 100px;
}

.project-not-found {
  text-align: center;
  padding: 80px 20px;
  background: linear-gradient(to bottom, #ffffff, #f8f9fa);
  border-radius: 12px;
  margin: 20px;
}

.project-not-found h1 {
  font-size: 2.5rem;
  margin-bottom: 20px;
  color: #333;
}

.project-not-found p {
  font-size: 1.2rem;
  color: #666;
  margin-bottom: 30px;
}
</style>